/**
 * 异步json获取
 * @desc 封装ajax
 * @param {String} url 接口地址
 * @param {Object} param 发送数据
 *
 * @param {Function} [success] 成功回调
 * @param {Function} [error] 错误回调
 */
function getJson(url, param, success, error) {
    param['JSESSIONID'] = sessionStorage.getItem('JSESSIONID');
    $.ajax({
        type: "POST",
        url: clientRoot + url,
        async: true,
        data: param,
        dataType: "json",
        success: function (data) {
            if (typeof success == "function") {
                success(data);
            } else {
                console.info("send:" + JSON.stringify(param) + "\nto:" + url + "\nreturn:\n" + JSON.stringify(data, null, 4))
            }
        },
        error: function (msg) {
            if (typeof error == "function") {
                error(msg);
            } else {
                console.error("send:" + JSON.stringify(param) + "\nto:" + url + '\nstatus:' + msg.status + "\nreturn:\n" + JSON.stringify(msg))
            }
        }
    });
}
// 时间戳转换
function add0(m){return m<10?'0'+m:m }
function changeDateFormat(shijianchuo) {
    var time = new Date(shijianchuo);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
}
function GetQueryString(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}

$(document).keydown(function(event) {
    if (event.keyCode == 13) {
        $("#search").click();
    }
})